package com.eastfair.imaster.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.eastfair.annotation.model.EchoVO;
import com.eastfair.core.base.entity.Entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

import javax.validation.constraints.Size;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
import static com.eastfair.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

/**
 * <p>
 * 实体类
 * 新闻表
 * </p>
 *
 * @author zjn
 * @since 2021-11-10
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("o_news")
@ApiModel(value = "News", description = "新闻表")
@AllArgsConstructor
public class News extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 项目id
     */
    @ApiModelProperty(value = "项目id")
    @TableField(value = "project_id")
    @Excel(name = "项目id")
    private Long projectId;

    /**
     * 标题
     */
    @ApiModelProperty(value = "标题")
    @Size(max = 128, message = "标题长度不能超过128")
    @TableField(value = "title", condition = LIKE)
    @Excel(name = "标题")
    private String title;

    /**
     * 内容
     */
    @ApiModelProperty(value = "内容")
    @Size(max = 65535, message = "内容长度不能超过65535")
    @TableField(value = "content", condition = LIKE)
    @Excel(name = "内容")
    private String content;

    /**
     * 类型
     */
    @ApiModelProperty(value = "类型")
    @Size(max = 32, message = "类型长度不能超过32")
    @TableField(value = "type", condition = LIKE)
    @Excel(name = "类型")
    private String type;

    /**
     * 封面图片
     */
    @ApiModelProperty(value = "封面图片")
    @Size(max = 256, message = "封面图片长度不能超过256")
    @TableField(value = "cover_image_url", condition = LIKE)
    @Excel(name = "封面图片")
    private String coverImageUrl;

    /**
     * 语言环境
     */
    @ApiModelProperty(value = "语言环境")
    @Size(max = 8, message = "语言环境长度不能超过8")
    @TableField(value = "language_type", condition = LIKE)
    @Excel(name = "语言环境")
    private String languageType;

    /**
     * 使用主体
     */
    @ApiModelProperty(value = "使用主体")
    @Size(max = 16, message = "使用主体长度不能超过16")
    @TableField(value = "subject_type", condition = LIKE)
    @Excel(name = "使用主体")
    private String subjectType;

    /**
     * 排序
     */
    @ApiModelProperty(value = "排序")
    @TableField(value = "sequence")
    @Excel(name = "排序")
    private Integer sequence;

    /**
     * 排序修改时间
     */
    @ApiModelProperty(value = "排序修改时间")
    @TableField(value = "sequence_update_time")
    @Excel(name = "排序修改时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime sequenceUpdateTime;

    /**
     * 是否启用：1是；0否
     */
    @ApiModelProperty(value = "是否启用：1是；0否")
    @TableField(value = "is_enabled")
    @Excel(name = "是否启用：1是；0否")
    private Integer isEnabled;

    /**
     * 是否删除：1是；0否
     */
    @ApiModelProperty(value = "是否删除：1是；0否")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除：1是；0否")
    private Integer isDeleted;


    @Builder
    public News(Long id, Long createdBy, LocalDateTime createTime, Long updatedBy, LocalDateTime updateTime, 
                    Long projectId, String title, String content, String type, String coverImageUrl, 
                    String languageType, String subjectType, Integer sequence, LocalDateTime sequenceUpdateTime, Integer isEnabled, Integer isDeleted) {
        this.id = id;
        this.createdBy = createdBy;
        this.createTime = createTime;
        this.updatedBy = updatedBy;
        this.updateTime = updateTime;
        this.projectId = projectId;
        this.title = title;
        this.content = content;
        this.type = type;
        this.coverImageUrl = coverImageUrl;
        this.languageType = languageType;
        this.subjectType = subjectType;
        this.sequence = sequence;
        this.sequenceUpdateTime = sequenceUpdateTime;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
    }

}
